package com.ruoyi.adapayRefund.controller;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.adapayRefund.domain.AdapayRefund;
import com.ruoyi.adapayRefund.service.IAdapayRefundService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 退款请求记录Controller
 *
 * @author ch
 * @date 2022-02-25
 */
@RestController
@RequestMapping("/adapayRefund/adapayRefund")
public class AdapayRefundController extends BaseController
{
    @Autowired
    private IAdapayRefundService adapayRefundService;

    /**
     * 查询退款请求记录列表
     */
    @PreAuthorize("@ss.hasPermi('adapayRefund:adapayRefund:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdapayRefund adapayRefund)
    {
        startPage();
        List<AdapayRefund> list = adapayRefundService.selectAdapayRefundList(adapayRefund);
        return getDataTable(list);
    }

    /**
     * 导出退款请求记录列表
     */
    @PreAuthorize("@ss.hasPermi('adapayRefund:adapayRefund:export')")
    @Log(title = "退款请求记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdapayRefund adapayRefund)
    {
        List<AdapayRefund> list = adapayRefundService.selectAdapayRefundList(adapayRefund);
        ExcelUtil<AdapayRefund> util = new ExcelUtil<AdapayRefund>(AdapayRefund.class);
        return util.exportExcel(list, "退款请求记录数据");
    }

    /**
     * 获取退款请求记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('adapayRefund:adapayRefund:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adapayRefundService.selectAdapayRefundById(id));
    }

    /**
     * 新增退款请求记录
     */
    @PreAuthorize("@ss.hasPermi('adapayRefund:adapayRefund:add')")
    @Log(title = "退款请求记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdapayRefund adapayRefund)
    {
        return toAjax(adapayRefundService.insertAdapayRefund(adapayRefund));
    }

    /**
     * 修改退款请求记录
     */
    @PreAuthorize("@ss.hasPermi('adapayRefund:adapayRefund:edit')")
    @Log(title = "退款请求记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdapayRefund adapayRefund)
    {
        adapayRefund.setUpdateType(DicConstants.BUSINESS_Manager.getCode());
        return toAjax(adapayRefundService.updateAdapayRefund(adapayRefund));
    }

    /**
     * 删除退款请求记录
     */
    @PreAuthorize("@ss.hasPermi('adapayRefund:adapayRefund:remove')")
    @Log(title = "退款请求记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adapayRefundService.logicDeleteAdapayRefund(ids,DicConstants.BUSINESS_Manager.getCode(),SecurityUtils.getUserId()));
    }
}
